import { defineStore } from "pinia";
import { ref, reactive } from 'vue';

// 类型
interface ObjType {
  name: string,
  age: number,
  address: string
}

export const useIndex = defineStore('index', () => {
  const val = ref(1);
  const obj: ObjType = reactive({
    name: "苏普路",
    age: 31,
    address: "河北省邯郸市鸡泽县",
    car: "奥迪 A6L"
  })

  const getObjProperty = <K extends keyof ObjType>(key: K) => {
    return obj[key];
  }

  return {
    obj,
    val,
    getObjProperty
  }
})